home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-1294.lzh / AMOSLIST / text0032.txt < prev    next >
Encoding:
Text File  |  1995-01-03  |  3.4 KB  |  97 lines

  1. > > > Well, about dynamic banks...
  2. > > > I thought on them for some time and cannot Paul add a 
  3. > > > Banklenghtadd(bytes) command? 
  4. > > > I don't know, call it Elbnkadd(number,bytes)
  5. > > > or better Elbnkadd(number of the bank, position, bytes).
  6. > > > This will solve many problems.
  7.  
  8. It might do, but it would only reserve a new longer bank, and copy old one over
  9. it, then delete the original and call bankswap to change the numbers (Which was
  10. the original solution to this problem). As this is 
  11.  
  12. a) Only a few lines of code
  13.  
  14. b) Rarely Executed (I.E. It wouldn't be in a fast loop)
  15.  
  16. c) Crap coding anyway is it uses at least double the memory of the bank
  17.  
  18. I don't think it is worth adding to easylife. A much better solution is to use
  19. some form a dynamic memory allocation - I.E. instead of making the
  20. bank larger, reserve another bank for the extra data. 
  21.  
  22. In practice its easier to reserve memory for each structure seperately, 
  23. which is what both easylife & makelib do.
  24.  
  25.  
  26. > > > Poking directly with the bank's lenght is quite dangerous as you could 
  27. > > > overlap memory used for something else.
  28.  
  29. Quite dangerous is an understatement. DON'T DO THIS.
  30.  
  31.  
  32.  
  33. > > > And copying the bank is quite slow if you have a large bank. 
  34. > > > 
  35. And memory consuming as it requires a large amount of unfragmented
  36. memory.
  37.  
  38. > > > Any ideas or comment?
  39. > > > 
  40. > >     How about using MakeLib extension (1.6kb) which has some nice mem.
  41. > >     allocation + list handling routines ??
  42. > > 
  43. > >     Like:
  44. > > 
  45. > >     BUFFER = Ma Malloc (1024,MEM_PUBLIC)
  46. > >     if BUFFER
  47. > >         <Do what ever you want to do for BUFFER (1024 bytes)>
  48. > >         Ma Free (BUFFER) : Rem Free BUFFER
  49. > >     End If
  50. > > 
  51. > >     You can also forget Ma Free or can use Ma Free All (Which is
  52. > >     automatically executed when quitting AMOSPro or compiled AMOS
  53. > >     program)
  54. > > 
  55. > >     This is something I call _dynamic_ memory allocationg AMOS banks(tm)
  56. > >     sucks.
  57.  
  58. I don't call this dynamic. It is only as dynamic as:
  59.  
  60. trap Reserve as work bnkno,1024
  61. if not errtrap
  62.     'Do whatever
  63.     Erase bnkno
  64. endif
  65.  
  66. Makelib's linked list structure is dynamic, but is restrictive in that it is 
  67. only
  68. a list - you can't build arbitary structures, and accessing the elements of
  69. the list still involves poking & peeking the memory of the list. Whilst this is
  70. faster than easylife's structures representation it does mean that you have
  71. no type-checking on the list elements, and if you change the format of the
  72. data poked/peeked you have to rewrite your code, not to mention the
  73. readability stinks.
  74.  
  75. However the linked list is still a much better solution than trying to use
  76. Ma Alloc, or Reserve as work for this purpose.
  77.  
  78. > Where I can find the MakeLib extension?
  79.  
  80. It is on nic.funet.fi in the /systems/amiga/programming/amos directory. 
  81. Don't ask me why when there is an aminet mirror at the same site!
  82.  
  83.  
  84. +-------------------------+------------------------------------+
  85. |                         |    _____                           |
  86. | PAUL HICKMAN            |   /     \   ON A HOT SUMMER NIGHT  |
  87. | (ph@doc.ic.ac.uk)       |  /  O O  \  WOULD YOU  OFFER YOUR  |
  88. | DEPARTMENT OF COMPUTING | |    _    | THROAT  TO  THE  WOLF  |
  89. | IMPERIAL COLLEGE LONDON |  \  / \  /  WITH THE RED  ROSES ?  |
  90. |                         |   \_____/                          |
  91. +-------------------------+------------------------------------+
  92. Machines: Amiga 500  WB1.3 - 1mb Memory - External Disk Drive.
  93.           Amiga 1200 WB3.0 - 6mb Memory - 200Mb Hard Disk.
  94.  
  95.  
  96.